#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main() {
    int n = 0, m = 0, a = 0, b = 0;
    scanf("%d %d", &m, &n);

    int r = m > n ? n : m;
    for (int i = r; i > 0; i--)
    {
        if (m % i == 0 && n % i == 0)
        {
            a = i;
            break;
        }
    }

    r = m < n ? n : m;
    for (int i = r; i > 0; i++)
    {
        if (i % m == 0 && i % n == 0)
        {
            b = i;
            break;
        }
    }

    printf("%d\n", a + b);

    return 0;
}